import React from 'react';
import './style.css';
class confirmComponent extends React.Component{
    constructor(){
        super();
        this.state={
            massge:'',
            btns:[]
        };
        this.aDiv=null;
    }
    setMages(mags,btns,div){
        this.setState({massge:mags,btns:btns});
        this.aDiv=div;
    }
    btnsFrom(index){
        if(this.state.btns[index].onPress){
            this.state.btns[index].onPress()
        }
        document.body.removeChild(this.aDiv);
    }
    render(){
        return(
            <div className='confirmBg'>
                <div className='confirmCen'>
                    <div className='confirmTitle'>{this.state.massge}</div>
                    <div className='confirmCenBtn'>
                        {
                            this.state.btns.length>0 && this.state.btns.map((item,index)=>{
                                return(
                                    <div className='confirmBtn ' key={index} onClick={this.btnsFrom.bind(this,index)}>{item.text}</div>
                                )
                            })
                        }
                      
                    </div>
                </div>
            </div>
        )
    }
}
export default confirmComponent